/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024.
 *
 * Description: The header file provides C preprocessor macros for use of
 * the ARMv8.3-PAuth extension in asm code.
 * Author: wanghuizhao
 * Create: 2024-5-30
 */
#ifndef ASM_RTOS_PAUTH_H
#define ASM_RTOS_PAUTH_H

/**
 * Wrapper asm file macro
 *
 * Strips the authentication code from an pointer.
 */
	.macro rtos_clear_pac tmp
	xpaci	\tmp
	xpacd	\tmp
	.endm

/**
 * Wrapper asm file macro
 *
 * Strips the authentication code from an pointer.
 */
	.macro rtos_blr_aut tmp1, tmp2
#ifdef CONFIG_RTOS_PAC_FORWARD_CFI_BKEY
	autib	\tmp1, \tmp2
#else
	autia	\tmp1, \tmp2
#endif
	blr	\tmp1
	.endm

/**
 * Wrapper asm file macro
 *
 * paci sign instrucions and modifier is sp
 */
	.macro rtos_pacisp
#ifdef CONFIG_RTOS_PAC_BACKWARD_CFI_AKEY
	paciasp
#else
	pacibsp
#endif
	.endm

/**
 * Wrapper asm file macro
 *
 * ret aut instrucions and modifier is sp
 */
	.macro rtos_ret_aut
#ifdef CONFIG_RTOS_PAC_BACKWARD_CFI_AKEY
	autiasp
#else
	autibsp
#endif
	ret
	.endm

#endif
